package com.gxyk.fragment;

import android.support.v4.app.Fragment;
import android.view.View;
import android.view.ViewGroup;

public abstract class BaseFragment extends Fragment {

	protected View rootView;
	private boolean hasInit;

	protected View getRootView(int layout) {
		if (rootView == null)
			rootView = View.inflate(getActivity(), layout, null);
		ViewGroup parent = (ViewGroup) rootView.getParent();
		if (parent != null) {
			parent.removeView(rootView);
		}
		if (!hasInit) {
			findView();
			fillData();
			hasInit = true;
		}
		return rootView;
	}

	protected abstract void fillData();

	protected abstract void findView();
}
